<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    // 克隆 拷贝
    var obj = {
      a: 10,
      b: 20,
      c: 30
    }
  /*   var obj2 = {};
    for(var key in obj) {
      obj2[key] = obj[key];
    } */
    // var obj2 = JSON.parse(JSON.stringify(obj))

    // 浅克隆 Object.assign 合并对象
    /* var obj2 = Object.assign({},obj);
    obj2.a = 1000;
    console.log(obj); */
    var obj2 = {
      ...obj
    }
    obj2.a = 1000;
    console.log(obj);
  </script>
</body>
</html>